package com.jzy.gulimall.order.web;

import com.jzy.gulimall.order.service.OrderService;
import com.jzy.gulimall.order.util.AliPayUtil;
import com.jzy.gulimall.order.vo.PayVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author jzy
 * @date 2020/9/23 9:00
 */
@RestController
public class PayController {

    @Resource
    private AliPayUtil aliPayUtil;

    @Resource
    private OrderService orderService;

    /**
     * aiPay支付
     */
    //@GetMapping(value = "/aliPay",produces = "text/html") 指定返回类型
    @GetMapping("/aliPay")
    public String aliPay(@RequestParam("orderSn")String orderSn){
        PayVo payVo = orderService.getOrderPayInfo(orderSn);
        if (payVo != null) {
            //aiPay支付
            return aliPayUtil.aliPay(payVo);
        }
        return "订单不存在";
    }
}
